package com.mogist.hqc.module.product.presenter

import com.google.gson.reflect.TypeToken
import com.mogist.hqc.entitys.BaseResponse
import com.mogist.hqc.entitys.response.DayPriceVo
import com.mogist.hqc.module.product.contract.ProductChooseContract
import com.mogist.hqc.mvp.HttpDto
import com.mogist.hqc.mvp._PresenterImpl
import com.mogist.hqc.util.Constant
import talex.zsw.basecore.util.JsonTool
import talex.zsw.basecore.view.dialog.sweetalertdialog.SweetAlertDialog

/**
 * 作用：选择类型/日期/人数
 * 作者：赵小白 email:vvtale@gmail.com  
 * 修改人：
 * 修改时间：
 * 修改备注：
 */
class ProductChoosePresenter(view: ProductChooseContract.View) : _PresenterImpl<ProductChooseContract.View, BaseResponse>(
        view), ProductChooseContract.Presenter
{
    override fun requestSuccess(response: BaseResponse, http: HttpDto)
    {
        when (http.url)
        {
            Constant.PRODUCT_DAILY_PRICE ->
            {
                if (response.success)
                {
                    mView.disDialog()
                    val list =
                            JsonTool.getObject(response.content,
                                               object : TypeToken<ArrayList<DayPriceVo>>()
                                               {})
                    mView.bindPrice(list as ArrayList<DayPriceVo>?)
                }
                else
                {
                    mView.showDialog(SweetAlertDialog.ERROR_TYPE,"获取产品日价格失败",response.message)
                }
            }
        }
    }
}